package com.collection.linkedlist;

import java.util.LinkedList;

public class RemoveAllElementsLinkedListExample {
	 public static void main(String[] args) {
		 
		    //create LinkedList object
		    LinkedList lList = new LinkedList();
		 
		    //add elements to LinkedList
		    lList.add("1");
		    lList.add("2");
		    lList.add("3");
		    lList.add("4");
		    lList.add("5");
		 
		    System.out.println("LinkedList contains : " + lList);
		   
		    /*
		     * To remove all elements of Java LinkedList, use
		     * void clear() method.
		     *
		     * This method remove all elements from LinkedList object.
		     */
		   
		     lList.clear();
		     System.out.println("LinkedList now contains : " + lList);
		   
		     /*
		      * Please note that removeAll method can also be used to remove
		      * all elements from LinkedList.
		      */
		  }
}
